package top.chendawei.system.beans.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.List;

@Data
@Entity
@Table(name = "sys_user")
public class SysUser implements Serializable {
    private static final long serialVersionUID = -1L;
    @GenericGenerator(name = "generator", strategy = "native")
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "id", unique = true, nullable = false)
    private Long id;
    @Column(name = "username", unique = true, length = 100)
    private String username;
    @Column(name = "pwd", length = 100)
    private String password;

    @Column(name = "email", length = 100)
    private String email;
    @Column(name = "mobile", length = 20)
    private String mobile;


    @Column(name = "realName")
    private String name;
    @Column(name = "nick_name")
    private String nickName;

    @Column(name = "avatar")
    private String avatar;
    @Column(name = "address")
    private String address;
    @Column(name = "position")
    private String position;

    @Column(name = "role_ids")
    private String roleIds;

    //, columnDefinition = "0锁住、1正常"
    @Column(name = "status")
    private Integer status;

    @Column(name = "reg_date")
    private String regDate;

    @Column(name = "login_date")
    private String loginDate;
    //, columnDefinition = "密码错误次数"
    @Column(name = "err_times")
    private Integer errTimes;

    //记载cookie的时间，过期时候剔除（或者刷新）
    @Transient
    private Long t;

    @Transient
    private String token;

    @Transient
    private List<SysRole> sysRoles;
    @Transient
    private List<Long> roleIdList;
}
